Imports System.Data.OleDb
Imports System.Data.OracleClient
Namespace Web.page

    Public Class myDBConn
        Const ConnStr As String = "DATA SOURCE=BSPT2;USER ID=sysadm;PASSWORD=sysadm;"

        Public Shared Function myOleDbTable(ByVal SQL As String) As DataTable
            Dim cn As OleDbConnection
            Dim dsTemp As DataSet
            Dim dsCmd As OleDbDataAdapter
            Dim ConnSt As String

            ConnSt = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db\ccapps.mdb"
            cn = New OleDbConnection(ConnSt)

            dsCmd = New OleDbDataAdapter(SQL, cn)
            dsTemp = New DataSet
            dsCmd.Fill(dsTemp, "Query")
            Return dsTemp.Tables(0)
            dsTemp.Dispose()
        End Function

        Public Shared Function myORATable(ByVal SQL As String) As DataTable
            Dim cn As OracleConnection
            Dim dsTemp As DataSet
            Dim dsCmd As OracleDataAdapter

            cn = New OracleConnection(ConnStr)

            dsCmd = New OracleDataAdapter(SQL, cn)
            dsTemp = New DataSet
            dsCmd.Fill(dsTemp, "Query")
            cn.Close()

            Return dsTemp.Tables(0)
            dsTemp.Dispose()
        End Function
        Public Function myOraResult(ByVal SQL As String) As ArrayList 'OracleDataReader
            Dim cn As OracleConnection
            Dim dbcmd As OracleCommand
            Dim reader As OracleDataReader
            Dim dsTemp As DataSet
            Dim dsCmd As OracleDataAdapter
            Dim list As ArrayList

            cn = New OracleConnection(ConnStr)
            cn.Open()

            dbcmd = cn.CreateCommand
            dbcmd.CommandText = SQL
            reader = dbcmd.ExecuteReader(CommandBehavior.CloseConnection)
            Dim lst As New ArrayList
            lst.Add(reader)


            Return lst

        End Function

        Public Function Execute(ByVal SQL As String) As Long

            Dim ConnSt As String
            ConnSt = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db\ccapps.mdb"

            Dim cn As New OleDbConnection(ConnSt)
            Dim objCmd As New OleDbCommand(SQL, cn)
            Dim lngResult As Long = 0

            objCmd.Connection.Open()
            lngResult = objCmd.ExecuteNonQuery
            cn.Close()
            Return lngResult
        End Function

        Public Function ORAExecute(ByVal SQL As String) As Long

            Dim cn As New OracleConnection(ConnStr)
            Dim objCmd As New OracleCommand(SQL, cn)
            Dim lngResult As Long = 0

            objCmd.Connection.Open()
            lngResult = objCmd.ExecuteNonQuery
            cn.BeginTransaction.Commit()
            cn.Close()
            Return lngResult
        End Function


    End Class
End Namespace


